def length(str):
    if len(str)<8:
        return  0
    else:
        return  1
def complexity(str):
    flag1=flag2=flag3=flag4=0
    for i in str:
        if i.islower():
            flag1=1
        elif i.isupper():
            flag2=1
        elif i.isdecimal():
            flag3=1
        else :
            flag4=1
    if flag1+flag2+flag3+flag4>2:
        return 1
    else:
        return 0
def flashback(str):
    for j in range(len(str)-3):
        res = str[j:j+3]
        for t in range(j+1,len(str)-2):
            res2=str[t:t+3]
            if res==res2:
                    return 0
    return 1
print("Password Rating System\nInput q or Q exit")
while True:
    password=input("\npls input password:")
    lens=comp=flab=0
    if password=="Q" or password=="q":
        break
    if length(password):
        lens=1
    if complexity(password):
        comp=1
    if flashback(password):
        flab=1
    print("your password made {0} points".format(2+lens+comp+flab))
    if lens+comp+flab==3:
        print("Your password is perfect",end="")
    if lens==0:
        print("Password must be more than 8 characters in length.",end="")
    if comp==0:
        print("Password should contain at least two alphabetic characters and at least one numeric or special character.",end="")
    if flab==0:
        print("Duplicate string used.",end="")